<?php include('./templete/public/head.php') ?>
<body>

<!--搜索-->
<div class="comm-search">
    <div class="search-input">
        <i class="iconfont icon-sousuo"></i>
        <input type="text" name="" id="title" value="<?php echo input('title') ?>" placeholder="请输入您要搜索的攻略"  onchange="search()"/>
    </div>
</div>
<!--搜索标签-->
<div class="search-tag">
    <div class="tag1">
        <a href="<?php echo url('strategy',['label'=>1,'type'=>$type]) ?>"  class="<?php if(input('label')!=2){ ?>active <?php } ?>" >
            所有<?php echo $topic_name?></a>
        <a href="<?php echo url('strategy',['label'=>2,'type'=>$type]) ?>" class="<?php if(input('label')==2){ ?>active <?php } ?>">我的<?php echo $topic_name?></a>
        <a href="<?php echo url('travel/publish_strategy',['type'=>$type]) ?>" >发布<?php echo $topic_name?></a>
    </div>
</div>
<hr class="bgcolor"/>

<!--所有攻略-->
<div class="index-main all-strategy">
    <div class="main-content strategy-content">

        <div class="c-list">
            <?php foreach ($list as $v){ ?>
            <div  class="list-item clearfix">
                <a href="<?php echo url('strategy_detail',['id'=>$v['id']]) ?>">
                <div class="item-img fl">
                    <img src="<?php echo $v['user_head'] ?>" class="head-img" />
                </div>
                <div class="item-detail">
                    <div class="detail1">
                        <span class="tag color1"><?php echo $title_head?></span>
                        <p class="title pfbold one-txt-cut">
                            <?php echo $v['title'] ?>
                        </p>
                    </div>
                    <div class="detail2">
                        <span><?php echo $v['appreciate'] ?> &nbsp;点赞</span>
                        <span><?php echo $v['comment'] ?> &nbsp;评论</span>
                    </div>
                    <div class="detail3">
                        <div class="text">
                           <?php echo $v['content'] ?>
                        </div>
                    </div>
                </a>
                    <div class="detail4">
                        <p><?php echo $v['author_name'] ?>：<?php echo date('Y-m-d H:i:s',strtotime($v['add_time'])) ?></p>
                        <p><?php echo $v['status']==1?'进行中':'已关闭' ?></p>
                    </div>
                </div>
            </div>
            <?php } ?>
        </div>
    </div>
</div>
</body>

</html>
<script>


    $(function() {
        var page = 2;
        var load_flag = true;
        $(window).scroll(function() {
            var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
            var documentheight = parseFloat($(document).height());
            var title=$('#title').val();
            var label = <?php echo $label ?>;
            if (documentheight - totalheight <= 200) {
                $("#loadmore").show();
                if(load_flag){
                    load_flag=!load_flag;
                    $.ajax({
                        url: '/index/travel/strategy_page.html',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            page:page,
                            title:title,
                            label:label,
                            type:<?php echo $type?>,
                            status:'<?php echo $status?>'
                        },
                        success: function(data) {
                            if (data.length) {
                                $.each(data,function(k, v) {
                                    if(v.status==1){
                                        var status ='进行中';
                                    }else{
                                        status = '已关闭';
                                    }
                                    var html = '<a href="/index/travel/strategy_detail/id/'+v.id+'" class="list-item clearfix">' +
                                        '<div class="item-img fl">' +
                                        '<img src="'+v.user_head+'" class="head-img" />' +
                                        '</div>' +
                                        '<div class="item-detail">' +
                                        '<div class="detail1">' +
                                        '<span class="tag color1">旅游攻略</span>' +
                                        '<p class="title pfbold one-txt-cut">' +
                                         v.title +
                                        '</p>' +
                                        '</div>' +
                                        '<div class="detail2">' +
                                        '<span>'+v.appreciate+' &nbsp;点赞</span>' +
                                        '<span>'+v.comment+' &nbsp;评论</span>' +
                                        '</div>' +
                                        '<div class="detail3">' +
                                        '<div class="text">' +
                                         v.content +
                                        '</div>' +
                                        '</div>' +
                                        '<div class="detail4">' +
                                        '<p>'+v.author_name+'：'+v.add_time+'</p>' +
                                        '<p>'+status+'<i class="iconfont icon-dianzan"></i></p>' +
                                        '</div>' +
                                        '</div>' +
                                        '</a>';
                                    $(".c-list").append(html);
                                })
                                load_flag=!load_flag;
                                page++;
                            }
                        }
                    })
                }

            }
        });
    });

    function search() {
        var title=$('#title').val();
        window.location.href="/index/travel/strategy.html?title="+title+'&type='+<?php echo $type?>;
    }
</script>